﻿function addRoleToDepartment(button)
{
    var bar = $(button.parentNode);
    var idInput = bar.find("input[name=id]");
    var nameInput = bar.find("input[name=name]");
    var argsVariable = new Object();
    var answer = window.showModalDialog("/Role/AddRoleToDepartment.aspx?departmentId="
        +idInput.val() +"&departmentName="+nameInput.val()+"",
        argsVariable, 
        "dialogWidth:300px; dialogHeight:200px; dialogLeft:250px; dialogTop:200px; center:yes;resizable:no;status:no; statusbar:no; toolbar:no; menubar:no; addressbar:no; titlebar:no;");
}

function viewRolesInDepartment(button)
{
    var line = $(button.parentNode);
    var idInput = line.find("input[name=id]");
    window.location.href = "/Role/RoleInDepartment.aspx?departmentId="+idInput.val();
}

function removeRoleFromDepartment(button)
{
    var bar = $(button.parentNode);
    var idInput = bar.find("input[name=hdfRoleId]");
    var deptIdInput = $("#refreshForm").find("input[name=hdfDepartmentId]");
    var argsVariable = new Object();
    var answer = window.showModalDialog("/Role/RemoveRoleFromDepartment.aspx?roleId="+idInput.val() + "&departmentId=" + deptIdInput.val(),
        argsVariable, 
        "dialogWidth:300px; dialogHeight:200px; dialogLeft:250px; dialogTop:200px; center:yes;resizable:no;status:no; statusbar:no; toolbar:no; menubar:no; addressbar:no; titlebar:no;");
}

function addRole()
{
    var src = "/Role/AddRole.aspx";
    $("#detailFrame").attr("src", src);
}

function viewRole(node)
{
    var bar = $(node.parentNode).next();
    var idInput = bar.find("input[name=id]");
    var src = "/Role/ViewRole.aspx?id="+idInput.val();
    $("#detailFrame").attr("src", src);
}

function editRole(button)
{
    var bar = $(button.parentNode);
    var idInput = bar.find("input[name=id]");
    var src = "/Role/EditRole.aspx?id="+idInput.val();
    $("#detailFrame").attr("src", src);
}

function removeRole(button)
{
    var bar = $(button.parentNode);
    var idInput = bar.find("input[name=id]");
    var src = "/Role/RemoveRole.aspx?id="+idInput.val();
    $("#detailFrame").attr("src", src);
}